package com.xdtech.sys.vo;

import java.util.ArrayList;
import java.util.List;

import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.User;
import com.xdtech.web.freemark.item.GridColumn;

public class UserItem extends BaseItem{
	protected Long id;
	@GridColumn(title="登录名")
	protected String loginName;			//用户登录名
	@GridColumn(title="姓名")
	protected String name;        //姓名
	@GridColumn(title="性别",formatter={"M=男","F=女"})
	protected String sex;
	@GridColumn(title="状态",formatter={"0=<span style=\"color:red;\">禁用</span>","1=<span style=\"color:green;\">在用</span>"})
	protected String status;
	
//	private String password;
	
	protected String groupIds;
	
	protected List<Long> usergroupIds = new ArrayList<Long>();
	
	protected boolean isSuperuser = false;
	
	protected List<Long> roleIds = new ArrayList<Long>();
	
	public UserItem() {
		super();
//		getQueryFields().put("id", "id");
//		getQueryFields().put("sex", "sex");
//		getQueryFields().put("name", "name");
//		getQueryFields().put("loginName", "loginName");
//		getQueryFields().put("status", "status");
	}
	

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
		addQuerys("loginName", loginName);
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
		addQuerys("sex", sex);
	}

	

	public List<Long> getUsergroupIds()
	{
		return usergroupIds;
	}


	public void setUsergroupIds(List<Long> usergroupIds)
	{
		this.usergroupIds = usergroupIds;
	}


	public String getGroupIds() {
		return groupIds;
	}

	public void setGroupIds(String groupIds) {
		this.groupIds = groupIds;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
		addQuerys("name", name);
	}


	public String getStatus()
	{
		return status;
	}


	public void setStatus(String status)
	{
		this.status = status;
		addQuerys("status", status);
	}


	public List<Long> getRoleIds()
	{
		return roleIds;
	}


	public void setRoleIds(List<Long> roleIds)
	{
		this.roleIds = roleIds;
	}


	

//	public String getPassword() {
//		return password;
//	}
//
//
//	public void setPassword(String password) {
//		this.password = password;
//	}

	public boolean isSuperuser()
	{
		return isSuperuser;
	}


	public void setSuperuser(boolean isSuperuser)
	{
		this.isSuperuser = isSuperuser;
	}


	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static UserItem createItem(User user) {
		if (user==null) {
			return null;
		}
		UserItem userItem = new UserItem();
		BeanUtils.copyProperties(userItem, user);
		//自定义属性设置填充
		return userItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<UserItem> createItems(List<User> users) {
		List<UserItem> userItems = new ArrayList<UserItem>();
		for (User user : users) {
			userItems.add(createItem(user));
		}
		return userItems;
	}
	
	
	
}
